package com.eshop.utils;

import javax.validation.ConstraintValidatorContext;
import org.hibernate.validator.internal.constraintvalidators.hv.EmailValidator;
import com.eshop.exception.BadRequestException;
import cn.hutool.core.util.ObjectUtil;

public class ValidationUtil
{
    public static void isNull(final Object obj, final String entity, final String parameter, final Object value) {
        if (ObjectUtil.isNull(obj)) {
            final String msg = entity + " 不存在: " + parameter + " is " + value;
            throw new BadRequestException(msg);
        }
    }
    
    public static boolean isEmail(final String email) {
        return new EmailValidator().isValid((CharSequence)email, (ConstraintValidatorContext)null);
    }
}
